package com.demo.component;

import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author krystal
 * @date 2023/3/7 8:25
 */
@Component
public class BeanLifeComponent implements BeanNameAware {
    @Override
    public void setBeanName(String s) {
        System.out.println("执行了通知");
    }

    @PostConstruct
    public void postConstruct(){
        System.out.println("执行了@PostConstruct");
    }

    public void init(){
        System.out.println("执行了init-method方法");
    }

    @PreDestroy
    public void PreDestory(){
        System.out.println("执行了销毁方法");
    }
}
